<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>微分享-后台管理系统</title>
    <meta name="description" content="微分享-后台管理系统"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="shortcut icon" th:href="@{/static/img/favicon.ico}" />
    <link rel="stylesheet" th:href="@{/static/assets/css/amazeui.min.css}"/>
    <link rel="stylesheet" th:href="@{/static/assets/css/admin.css}"/>
    <link rel="stylesheet" th:href="@{/static/lib/layer/skin/layer.css}" />
    <script th:src="@{/static/assets/js/jquery.min.js}"></script>
    <script th:src="@{/static/assets/js/amazeui.min.js}"></script>
    <script th:src="@{/static/assets/js/app.js}"></script>
    <script th:src="@{/static/js/public.js}"></script>
	<script type= "text/javascript" th:src ="@{/static/lib/layer/layer.js}"></script>   
	<script type= "text/javascript" th:src ="@{/dwr/util.js}"></script>   
	<script type="text/javascript" th:src= "@{/dwr/engine.js}"></script > 
	<script type="text/javascript" th:src= "@{/dwr/interface/NoticeContentController.js}"></script>
	<script type="text/javascript" th:src= "@{/static/js/dwrhelp.js}"></script>
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
    以获得更好的体验！</p>
<![endif]-->

<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <strong>微分享</strong>
        <small>后台管理系统</small>
    </div>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
            <li class="am-dropdown" id="am-dropdown">
                <a class="am-dropdown-toggle"  href="javascript:;">
                    <span class="am-icon-users"></span> 管理员<span th:text="${session.userName}"></span><span class="am-icon-caret-down"></span>
                </a>
                <ul class="am-dropdown-content">
                  <li><a th:href="@{/admin-user}"><span class="am-icon-user"></span> 资料</a></li>
		          <li><a href="logout"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
            <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span
                    class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
        </ul>
    </div>
</header>

<div class="am-cf admin-main">
    <!-- sidebar start -->
    <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
        <div class="am-offcanvas-bar admin-offcanvas-bar">
            <ul class="am-list admin-sidebar-list">
                <li><a href="admin_index"><span class="am-icon-home"></span>内容管理</a></li>
                <li><a href="admin_users"><span class="am-icon-table"></span>用户管理</a></li>
                <li><a href="admin_add_pictureshare"><span class="am-icon-table"></span>添加分享</a></li>
				<li><a href="register"><span class="am-icon-table"></span>管理员注册</a></li>
                <li><a href="logout"><span class="am-icon-sign-out"></span> 注销</a></li>
            </ul>

            <div class="am-panel am-panel-default admin-sidebar-panel">
                <div class="am-panel-bd">
                    <p><span class="am-icon-bookmark"></span> 公告</p>
                    <p>时光静好，与君语；细水流年，与君同。</p>
                </div>
            </div>
        </div>
    </div>
    <!-- sidebar end -->

    <!-- content start -->
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">详情</strong>
                </div>
            </div>

            <div class="am-u-sm-12 am-u-sm-centered">
                <h4>用户名</h4>
                <p id="username"></p>
                <h4>创建时间</h4>
                <time id="createdOn"></time>
                <h4>详情</h4>
                <p id="remark"></p>
                <h4>图片列表</h4>
                <ul class="am-avg-sm-2 am-avg-md-4 am-avg-lg-6 am-margin gallery-list">
                    <div id="picture_content" class="container-fluid" align="center">
                    </div>
                </ul>
                <h4>评论列表</h4>
                <div id="commentList" class="am-g">
                    <div class="am-u-sm-12">
                        <table class="am-table am-table-bd am-table-striped admin-content-table">
                            <thead>
                            <tr>
                                <th>用户名</th>
                                <th>时间</th>
                                <th>评论详情</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="commentContent">

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!-- content end -->
        <footer class="admin-content-footer">
        	<hr/>
            <p class="am-padding-left">周航@成都信息工程大学, All Rights Reserved.</p>
        </footer>
    </div>

    <!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
   data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
<script th:src="@{/static/js/jquery.lightbox.js}"></script>
<script>
/*<![CDATA[*/
    function loadS(url) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = url;
        document.head.appendChild(script);
    }

    var pictureShareId = getURLParameter("pictureShareId");
    $.ajax({
        url: "/picture_share_detail",
        data: {
            pictureShareId: pictureShareId
        },
        success: function (msg) {
        	console.info(msg);
            if (msg.success) {
                var json = msg.obj;
                $("#username").text(json.userName);
                $("#createdOn").text(json.createdOn);
                $("#remark").text(json.remark);

                var comments = json.commentDtoList;
                if (comments.length == 0) {
                    $("#commentList").empty();
                    $("#commentList").append("无");
                } else {
                	var t = '<tbody id="content">';
                    $("#commentContent").append(t);
                    for (var i = 0; i < comments.length; i++) {
                        $("#commentContent").append("<tr>\n" +
                                "                            <td  style=\"width: 20%\">" + comments[i].userName + "</td>\n" +
                                "                            <td  style=\"width: 20%\">" + comments[i].createdOn + "</td>\n" +
                                "                            <td  style=\"width: 20%\">" + comments[i].comment + "</td>\n" +
                                "                            <td  style=\"width: 20%\">" + "<button onclick='deleteComment(" + comments[i].id + ")' class=\"am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only\"><span class=\"am-icon-trash-o\"></span> 删除</button>" + "</td>\n" +
                                "                        </tr>");
                    }
                    $("#commentContent").append("</tbody>");
                }

                var files = json.fileURLList;
                if (files.length == 0) {
                    $("#picture_content").append("无");
                } else {
                    for (var i = 0; i < files.length; i++) {
                        $("#picture_content").append("<div class=\"col-md-2 col-sm-6\">\n" +
                                "                            <div class=\"gallery-item\">\n" +
                                "                                <div class=\"image\">\n" +
                                "                                    <div class=\"overlay\">\n" +
                                "                                        <a href=fileupload/" + files[i] + "\" data-rel=\"lightbox\" class=\"fa fa-expand\"></a>\n" +
                                "                                    </div>\n" +
                                "                                    <img src=\"fileupload/" + files[i] + "\" alt=\"image 2\">\n" +
                                "                                </div>\n" +
                                "                                <div class=\"content-gallery\"></div>\n" +
                                "                            </div>\n" +
                                "                        </div>");
                    }
                    loadS("static/js/templatemo_custom.js");
                }
            }
        }
    });
    function deleteComment(commentId) {
        $.ajax({
            url:"/del_comment/" + commentId,
            data: {
            },
            success: function (msg) {
           	   	if (msg) {
                    alert("删除成功");
                    window.location.reload();
                }
            }
        });
    }
    /*]]>*/
</script>
</body>
</html>
